<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with VictoryCMS.  If not, see <http://www.gnu.org/licenses/>.

/**
 * VictoryCMS - FolderMap
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @filesource
 * @package VcmsCore
 */

/**
 * This class represents a mapping of folders to
 * concrete folder names on the file system.
 * Note: This must be in the same folder as VcmsMain.php.
 *
 * @package VcmsCore
 * 
 * @todo do existance and permission checks to make sure everything is A-OK.
 */
class FolderMap {

	/**
	 * Returns a path to the document root of the
	 * currently running php script as set by
	 * $_SERVER['DOCUMENT_ROOT'].
	 *
	 * @return String A path to the document root web folder
	 * with a trailing slash.
	 */
	public static function getHomeDirPath() {
		if($_SERVER['DOCUMENT_ROOT'] == '' || !isset($_SERVER['DOCUMENT_ROOT'])){
			throw new DataException('Document Root');
		}
		return $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR;
	}

	/**
	 * Returns the path to the includes folder, which should be located
	 * in the document root set in $_SERVER['DOCUMENT_ROOT'] with a 
	 * trailing slash.
	 */
	public static function getIncludeFolder() {
		$includes = self::getHomeDirPath().'include'.DIRECTORY_SEPARATOR;
		return $includes;
	}

	/**
	 * Returns the path of the folder containing core DisplayablePages.
	 * @return string A path to the folder containing core DisplayablePages.
	 */
	public static function getPageFolder() {
		return self::getIncludeFolder().'displayable_pages'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the testing DisplayablePages folder.
	 * @return string A path to the testing DisplayablePages folder.
	 */
	public static function getTestingPageFolder() {
		return self::getPageFolder().'test_pages'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the PageBuilder folder.
	 * @return string A path to the PageBuilder folder.
	 */
	public static function getPageBuilderFolder() {
		return self::getIncludeFolder().'pagebuilders'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the testing PageBuilder folder.
	 * @return string A path to the testing PageBuilder folder.
	 */
	public static function getTestingPageBuilderFolder() {
		return self::getPageBuilderFolder().'page_builder_testing'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the database abstraction folder.
	 * @return string A path to the database abstraction folder.
	 */
	public static function getDALFolder() {
		return self::getIncludeFolder().'database_abstraction_layer'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the query sets folder.
	 * @return string A path to the query sets folder.
	 */
	public static function getQuerySetFolder() {
		return self::getIncludeFolder().'query_sets'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the html abstraction folder.
	 * @return string A path to the html abstraction folder.
	 */
	public static function getHALFolder() {
		return self::getIncludeFolder().'html_abstraction_layer'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the exceptions folder.
	 * @return string A path to the exceptions folder.
	 */
	public static function getExeceptionFolder() {
		return self::getIncludeFolder().'exceptions'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the components folder.
	 * @return string A path to the components folder.
	 */
	public static function getComponentFolder() {
		return self::getIncludeFolder().'components'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the models folder.
	 * @return string A path to the models folder.
	 */
	public static function getModelsFolder() {
		return self::getIncludeFolder().'models'.DIRECTORY_SEPARATOR;
	}
	
	/**
	 * Returns a path to the external includes folder.
	 * @return string A path to the external includes folder.
	 */
	public static function getExternalIncludeFolder() {
		return self::getIncludeFolder().'external'.DIRECTORY_SEPARATOR;
	}
}
?>
